<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
		<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
		<title>投票历史列表</title>
		<link rel="stylesheet" type="text/css" href="../css/api.css"/>
		<link rel="stylesheet" href="../../css/mui.min.css">
		<link rel="stylesheet" type="text/css" href="../../css/base.css">
		<link rel="stylesheet" href="../../css/weui.min.css">
		<style>
			body {
			}
			.mui-table-view-cell:active {
				background: #fff;
			}
			.mui-table-view-cell > a:not(.mui-btn) {
				padding: 10px;
			}
			.cell-title {
				height: 22px;
			}
			.cell-subtitle, .message_content {
				height: 20px;
			}
			.right-div {
				width: 70px;
				float: right;
				padding: 15px 2px;
			}
			.left-div {
				margin-right: 70px;
				margin-top: 2px;
			}
			.message_title {
				width: 90%;
				color: #222222
			}
			.right-tag {
				text-align: right;
			}
			.mui-table-view .mui-media-object {
				margin-top: 5px;
			}
			.discuss-del {
				width: 18px;
				margin-right: 0px;
			}
			.discuss-del-div {
				text-align: right;
				height: 40px;
				padding-top: 8px;
			}
			.join_em {
				color: #18b4ed
			}
			.all_em {
				color: #333
			}
		</style>
	</head>
	<body>
		<div id="mian">
			<ul id="stulist" class="mui-table-view "  >
			<!--	<li class="mui-table-view-cell mui-media"  >
					<a  href="javascript:;" > <img class="mui-media-object mui-pull-left" src="../../image/icon_vote.png" >
					<div class="mui-media-body">
						<div class="right-div">
							<p class="mui-ellipsis base_grey content_p right-tag  font14">
								<span><em class="join_em">1</em><em class="all_em">/12</em></span>
								<span>参与</span>
							</p>
						</div>
						<div class="left-div">
							<p class="mui-ellipsis base_dark_grey font14 cell-title">
								<span class="message_title">调查1</span>
							</p>
							<p class="mui-ellipsis base_grey font14 content_p cell-subtitle ">
								<span class="file_submit_time top_2">2012-02-13</span>
							</p>
						</div>
					</div></a>
				</li>-->
			</ul>
		</div>
		<div class="noSign" hidden="hidden" id="noData">
			<img src="../../image/icon_img.png" width="60%">
			<p class="font16 top_15 base_dark_grey" >
				暂无数据
			</p>
		</div>
		<div class="loadFailure" hidden="hidden" id="noNet">
			<img src="../../image/icon_img01.png" width="60%">
			<p class="" >
				数据加载失败
			</p>
			<p>
				请检查您的网络
			</p>
			<button type="button"  onclick="refreshData()"class="mui-btn mui-btn-outlined">
				重新加载
			</button>
		</div>
		<!--删除微博-->
		<div id="logout" class="weui_dialog_confirm" style="display: none;">
			<div class="weui_mask"></div>
			<div class="weui_dialog">
				<div class="weui_dialog_hd">
					<strong class="weui_dialog_title" id="deleInfo">确定删除调查？</strong>
				</div>
				<div class="weui_dialog_ft">
					<a href="javascript:cancel();" class="weui_btn_dialog default" style="color:#18b4ed">取消</a>
					<a  href="javascript:confirm();" class="weui_btn_dialog primary" style="color:#18b4ed">确定</a>
				</div>
			</div>
		</div>
	</body>
	<script type="text/javascript" src="../../script/api.js"></script>
	<script type="text/javascript" src="../../script/MD5.js"></script>
	<script src="../../script/jquery.min.js" type="text/javascript"></script>
	<script type="text/javascript" src="../../script/requestTool.js"></script>
	<script type="text/javascript" src="../../script/timeStampTool.js"></script>
	<script src="../../script/common.js"></script>
	<script type="text/javascript" src="../../script/activityBottomPopup.js"></script>
	<script type="text/javascript">
		var page = 1;
		var rows = 10;
		var refreshCount = 0;
		var sid = '';
		var firstLoad = true;
		var itemIndex = "";
		apiready = function() {
						loadNewData();
			setRefreshHeader();
			setPullUpRefresh();
		};
		function sendBuriedNotifi(busionessid, pagetype, pagetypeid) {
			var userinfo = {
				uid : $api.getStorage('cfnetppuid'),
				jid : $api.getStorage('cfnetppjxid'),
				uname : $api.getStorage('cfnetppusername'),
			}
			var data = {
				busionessid : busionessid,
				pagetype : pagetype,
				pagetypeid : pagetypeid,
				sourceurl : api.pageParam.sourceurl,
				sourcetitle : api.pageParam.sourcetitle,
				accesspageurl : window.location.pathname,
				accesspagetitle : document.title,
				userinfo : userinfo
			}
			SendBehaviorTrajectoriesNotifi_Study(data);
		}

		//下拉刷新
		function setRefreshHeader() {
			api.setRefreshHeaderInfo({
				visible : true,
				bgColor : '#ccc',
				textColor : '#fff',
				textDown : '下拉刷新...',
				textUp : '松开刷新...',
				showTime : true
			}, function(ret, err) {
				loadNewData();
			});
		}

		// 上拉加载
		function setPullUpRefresh() {
			api.addEventListener({
				name : 'scrolltobottom'
			}, function(ret, err) {
				if (refreshCount >= rows) {
					loadMoreData();
				}
			});
		}

		function loadNewData() {
			page = 1;
			loadData();
		}

		function loadMoreData() {
			page++;
			loadData();
		}

		//获取数据
		function loadData() {
			if (firstLoad == true) {
				showProgress();
				firstLoad = false;
			}
			var params = {
//				jid:158,
//				uid:144563,
//				cid:17383,
//				pid:5805,
//				page:1,
//				rows:10,
//				tid:6,
				isapp:1,
				jid : $api.getStorage('cfnetppjxid'),
				uid : $api.getStorage('cfnetppuid'),
				page : page,
				rows : rows,
				tid : 6,
				cid : api.pageParam.cid,
				pid : api.pageParam.pid,
			};
			
			cfnetppPOST(url_activeList, params, true, function(data, status) {
				api.hideProgress();
				api.refreshHeaderLoadDone();
				if (status == 'success') {
					if (data.code == 200) {
						var listdata = data.data;
						if (listdata != '' && listdata.constructor == Array && listdata.length > 0) {
							$('#noData').hide();
							$('#noNet').hide();
							$('#mian').show();
							refreshCount = listdata.length;
							writelist(listdata, refreshCount);
						} else {
							if (page == 1) {
								$('#noData').show();
								$('#noNet').hide();
							}
						}
					} else if (data.code = 108) {
						if (page == 1) {
							$('#noData').show();
							$('#noNet').hide();
							$('#stulist').html('');
						}
					} else {
						if (page == 1) {
							$('#noData').show();
							$('#noNet').hide();
							$('#stulist').html('');
						}
					}
				} else {
					if (page > 1) {
						page--;
						refreshCount = rows;
						api.toast({
							msg : '网络异常'
						});
					} else {
						$('#noData').hide();
						$('#noNet').show();
						$('#stulist').html('');
					}
				}
			});
		}
				//填充ui布局
		function writelist(listdata, len) {
			var htmls = '';
			var status = '';
			for (var i = 0; i < len; i++) {
				var data = listdata[i];
				var starttime = data.starttime;
				var timeString = '';
				if (starttime == null || starttime == 0) {
					timeString = timeWithStamp3(data.createtime);
				} else {
					timeString = timeWithStamp3(starttime);
				}
				var userstatus = data.userstatus;
				
				var DataArr = JSON.stringify(data).replace(/"/g, '&quot;');
			
				var strhtml = 	'<li class="mui-table-view-cell mui-media" onclick="openwin(' + DataArr + ')" >'+
									'<a  href="javascript:;" > <img class="mui-media-object mui-pull-left" src="../../image/icon_vote.png" >'+
									'<div class="mui-media-body">'+
										'<div class="right-div">'+
											'<p class="mui-ellipsis base_grey content_p right-tag  font14">'+
												'<span><em class="join_em">'+data.num+'</em><em class="all_em">/'+data.countnum+'</em></span>'+
												'<span>参与</span>'+
											'</p>'+
										'</div>'+
										'<div class="left-div">'+
											'<p class="mui-ellipsis base_dark_grey font14 cell-title">'+
												'<span class="message_title">'+data.name+'</span>'+
											'</p>'+
											'<p class="mui-ellipsis base_grey font14 content_p cell-subtitle ">'+
												'<span class="file_submit_time top_2">'+timeString+'</span>'+
											'</p>'+
										'</div>'+
									'</div></a>'+
								'</li>';
				
				htmls = htmls + strhtml;
			}
			if (page == 1) {
				$('#stulist').html(htmls);
			} else {
				$('#stulist'
				).append(htmls);
			}
		}
		function openwin(data) {
				api.openWin({useWKWebView:true,
					name : 'Teacher_VoteScoreWindow',
					url : 'Teacher_VoteScoreWindow.html',
					pageParam : {
						cid : api.pageParam.cid,
						pid : api.pageParam.pid,
						iid : data.id,
						itemCheck  : data.template,
						ismocc : 'history',
						ishistory:true,
					}
				});
			}

		function refreshData() {
			firstLoad = true;
			loadNewData();
		}
	</script>
</html>